﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using RaisingStudio.Data.Providers;
using RaisingStudio.Data.Entities.MSPetShop4;

namespace UnitTest
{
    [TestFixture]
    public class MSPetShop4Test
    {
        private DataContext dc;

        private void CreateDataContext()
        {
            this.dc = new DataContext("sqlServer20005", "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"|DataDirectory|MSPetShop4.mdf\";Integrated Security=True;User Instance=True");
            this.dc.Log = System.Console.Out;
        }

        public MSPetShop4Test()
        {
            CreateDataContext();
        }

        ~MSPetShop4Test()
        {
            this.dc = null;
        }

        [TestFixtureSetUp]
        public void TestCaseSetup()
        {
        }

        [TestFixtureTearDown]
        public void TestCaseTearDown()
        {
        }

        [SetUp]
        public void Init()
        {
        }

        [TearDown]
        public void CleanUp()
        {
        }

        [Test]
        public void Test1()
        {
            Assert.IsNotNull(this.dc);
            Assert.IsNotNull(this.dc.Connection);
            Assert.IsNotNull(this.dc.Database);
            Assert.IsNotNull(this.dc.Provider);
            Assert.IsNotNull(this.dc.LogManager);
        }

        [Test]
        public void Test2()
        {
            Assert.Greater(this.dc.GetCount<Category>(), 0);
            Assert.Greater(this.dc.GetCount<Inventory>(), 0);
            Assert.Greater(this.dc.GetCount<Item>(), 0);
            Assert.Greater(this.dc.GetCount<Product>(), 0);
            Assert.Greater(this.dc.GetCount<Supplier>(), 0);
        }
    }
}
